package service;

import dao.UserDao;
import dao.UserDaoFactory;
import entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

//示例19-20-22-23-24
@Service("userService")
public class UserServiceImpl implements  UserService{
    @Autowired
    @Qualifier("userDao")
//    @Resource(name = "userDao")
    @Resource
    //声明接口类型的引用和具体实现类解耦合 示例17
    private UserDao dao;
    public void setDao(UserDao dao) {
        this.dao = dao;
    }
    public void setUserDao(UserDao userDao){
        this.dao=userDao;
    }
    public  void addNewUser(User user){
        dao.save(user);
    }
    //第六章
    public UserServiceImpl(){

    }
    public UserServiceImpl(UserDao dao){
        this.dao=dao;
    }


}
